package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("usershopcontroller")
@Slf4j
@Api(tags = "营业状态接口")
@RequestMapping("/user/shop")
public class ShopController {

    public static final String Key = "shop_status";

    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("查询店铺的营业状态")
    @GetMapping("/status")
    public Result<Integer> getstatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get(Key);
        log.info("查询店铺的营业状态为：{}", status == 1 ? "营业中" : "打烊了");
        return Result.success(status);
    }


}
